package priv.yiyuan.example.design.wrapper;

/**
 * 支付处理器
 * <p>
 * 策略模式-上下文
 *
 * @author YiYuan
 * @data 2025/9/2
 * @apoNote
 */
public class PaymentProcessor {

    private PaymentStrategy paymentStrategy;

    public void setPaymentStrategy(PaymentStrategy paymentStrategy) {
        this.paymentStrategy = paymentStrategy;
    }

    public void processPayment(double amount) {
        if (paymentStrategy == null) {
            System.out.println("未设置支付策略");
            return;
        }

        System.out.println("\n--- 开始处理支付, 支付方式: " + paymentStrategy.getDescription() + " ---");
        paymentStrategy.pay(amount);
        System.out.println("--- 支付处理完成 ---");
    }
}
